package com.ruoyi.web.controller.wlwsys.jintao;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.service.WlwsysProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.text.ParseException;

/**
 * @program: RuoYi-Vue-master
 * @Date: 2023-07-19 17:35
 * @author: jintao
 * @description: TODO
 */
@RestController
@RequestMapping("/project")
public class WlwProjectController extends BaseController {
    @Autowired
    private WlwsysProjectService wlwsysProjectService;

    //分页查询
    @PostMapping("/getListByPage")
    public TableDataInfo getListByPage(@RequestParam("pageNum")Integer pageNum, @RequestParam("pageSize")Integer pageSize,
    @RequestParam(value = "projectId",required = false)String projectId,@RequestParam(value = "projectName",required = false)String projectName,
    @RequestParam(value = "userId",required = false)Long userID,@RequestParam(value = "startTime",required = false)String startTime,
    @RequestParam(value = "endTime",required = false)String endTime) throws ParseException {
        return getDataTable(wlwsysProjectService.getProjectByPageInfo(pageNum,pageSize,projectId,projectName,userID,startTime,endTime));
    }

    //删除数据
    @PostMapping("/handDelete")
    public void handDelete(@RequestParam("projectId")String projectId){
        wlwsysProjectService.deleteByProjectId(projectId);
    }

    //更新数据
    @PostMapping("/sureUpdateMessage")
    public boolean sureUpdateMessage(@RequestParam(value = "projectId",required = false)String projectId,@RequestParam(value = "projectName",required = false)String projectName,
                                  @RequestParam(value = "projectIntroduce",required = false)String projectIntroduce) throws ParseException {
       return wlwsysProjectService.UpdateProject(projectId,projectName,projectIntroduce);
    }

    //添加项目
    @PostMapping("/sureAddProject")
    public void sureAddProject(@RequestParam(value = "projectName",required = false)String projectName,
                               @RequestParam(value = "projectIntroduce",required = false)String projectIntroduce) throws ParseException {
        wlwsysProjectService.insertProject(projectName,projectIntroduce,getUsername());
    }
}
